<?php
/**
 * @author Cristina Costache
 */
class Twitter
{
    /**
     * Check if a user's credentials map to a valid Twitter account
     * @param  string $username
     * @param  string $password
     * @return boolean
     */
	public function checkCredentials($username, $password)
	{
		$twitter  = new Zend_Service_Twitter($username, $password);
		$response = $twitter->account->verifyCredentials();

		return $response;
    }

    /**
     * Gets the most recents tweets from the current user
     * @param string $username
     * @param string $password
     * @return array
     */
    public function getTweets($username, $password)
    {
		$twitter  = new Zend_Service_Twitter($username, $password);
		$response = $twitter->status->userTimeline();

		$tweets = array();
		foreach ($response->status as $tweet) {
			$result = array();
			$result['timestamp'] = $tweet->created_at;
			$result['text'     ] = $tweet->text;
			$tweets[] = $result;
		}

		return $tweets;
    }

    /**
     * Show your current status
     * @param string $username
     * @param string $password 
     */
    public function showStatus($username, $password, $text)
    {
		$twitter = new Zend_Service_Twitter($username, $password);

		//show your status
		$response = $twitter->status->show(1234);
		return $response;
    }

    /**
     * Post a tweet to the user's twitter account
     * @param string $username
     * @param string $password
     * @param string $text
     */
    public function postTweet($username, $password, $text)
    {
		$twitter = new Zend_Service_Twitter($username, $password);

		// post the tweet
		$response = $twitter->status->update($text);
		return $response;
    }

    /**
     * Delete a tweet to the user's twitter account
     * @param string $username
     * @param string $password
     * @param string $text
     */
    public function deleteTweet($username, $password, $text)
    {
		$twitter = new Zend_Service_Twitter($username, $password);

		//delete the tweet
		$response = $twitter->status->Destroy(12345);
		return $response;
    }

    /**
     * Get your followers
     * @param string $username
     * @param string $password
     */
    public function getFollowers($username, $password)
    {
		$twitter = new Zend_Service_Twitter($username, $password);

		//get the followers
		$response = $twitter->user->followers();
    }
}